/* 网络拓扑图样式 */

.topology-container {
    height: 600px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* D3.js SVG容器 */
#topologySvg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#topologySvg:active {
    cursor: grabbing;
}

/* 节点样式 */
.node {
    cursor: pointer;
    transition: opacity 0.3s ease, filter 0.3s ease; /* 避免缩放干扰 D3 位置变换 */
}

.node:hover {
    stroke-width: 3px;
}

.node-internal {
    fill: #28a745;
    stroke: #1e7e34;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.node-external {
    fill: #ffc107;
    stroke: #e0a800;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.node-gateway {
    fill: #007bff;
    stroke: #0056b3;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.node-router {
    fill: #6f42c1;
    stroke: #5a32a3;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.node-server {
    fill: #fd7e14;
    stroke: #e55a00;
    stroke-width: 2px;
    vector-effect: non-scaling-stroke;
}

.node-selected {
    stroke: #dc3545;
    stroke-width: 4px;
    filter: drop-shadow(0 0 8px rgba(220, 53, 69, 0.6));
}

/* 连接线样式 */
.link {
    stroke: #999;
    stroke-opacity: 0.6;
    stroke-width: 2px;
    transition: all 0.3s ease;
    vector-effect: non-scaling-stroke;
}

.link:hover {
    stroke-opacity: 1;
    stroke-width: 4px;
}

.link-high-traffic {
    stroke: #dc3545;
    stroke-width: 3px;
}

.link-medium-traffic {
    stroke: #ffc107;
    stroke-width: 2px;
}

.link-low-traffic {
    stroke: #28a745;
    stroke-width: 1px;
}

/* 节点标签 */
.node-label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    font-weight: bold;
    fill: #333;
    text-anchor: middle;
    pointer-events: none;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.node-label-bg {
    fill: rgba(255,255,255,0.8);
    stroke: rgba(0,0,0,0.1);
    stroke-width: 1px;
    rx: 3;
    ry: 3;
}

/* 流量标签 */
.traffic-label {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 10px;
    fill: #666;
    text-anchor: middle;
    pointer-events: none;
}

/* 统计数字样式 */
.stat-number {
    font-size: 1.8rem;
    font-weight: bold;
    color: #495057;
}

/* 流量排行样式 */
.traffic-ranking {
    max-height: 300px;
    overflow-y: auto;
}

.traffic-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.traffic-item:last-child {
    border-bottom: none;
}

.traffic-rank {
    font-weight: bold;
    color: #007bff;
    min-width: 20px;
}

.traffic-node {
    flex: 1;
    margin: 0 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.traffic-value {
    color: #28a745;
    font-weight: bold;
}

/* 节点详情样式 */
.node-details {
    min-height: 200px;
}

.node-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

.node-detail-item:last-child {
    border-bottom: none;
}

.node-detail-label {
    font-weight: bold;
    color: #495057;
}

.node-detail-value {
    color: #6c757d;
    font-family: 'Courier New', monospace;
}

/* 图例样式 */
.topology-legend {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(255,255,255,0.95);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.legend-item:last-child {
    margin-bottom: 0;
}

.legend-node {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 8px;
    border: 2px solid;
}

.legend-node.internal {
    background-color: #28a745;
    border-color: #1e7e34;
}

.legend-node.external {
    background-color: #ffc107;
    border-color: #e0a800;
}

.legend-node.gateway {
    background-color: #007bff;
    border-color: #0056b3;
}

.legend-node.router {
    background-color: #6f42c1;
    border-color: #5a32a3;
}

.legend-node.server {
    background-color: #fd7e14;
    border-color: #e55a00;
}

/* 加载动画 */
.topology-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #6c757d;
}

.topology-loading .spinner {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .topology-container {
        height: 400px;
    }

    .topology-legend {
        position: relative;
        bottom: auto;
        left: auto;
        margin-top: 20px;
    }

    .stat-number {
        font-size: 1.4rem;
    }
}

/* 动画效果 */
@keyframes nodePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.node-active {
    animation: nodePulse 2s infinite;
}

/* 工具提示样式 */
.tooltip {
    position: absolute;
    padding: 8px 12px;
    background: rgba(0,0,0,0.8);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    max-width: 250px;
    word-wrap: break-word;
}

/* 控制面板增强 */
.form-select, .form-control {
    border: 1px solid #ced4da;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-select:focus, .form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* 按钮增强 */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* 卡片增强 */
.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
